<template>
  <transition name="el-loading-fade" @after-leave="handleAfterLeave">
    <div
      v-show="visible"
      class="el-loading-mask"
      :style="{ backgroundColor: background || '' }"
      :class="[customClass, { 'is-fullscreen': fullscreen }]"
      >

      <div class="el-loading-spinner1">
        <div class="top">
            <div class="top1">
               <div id="num" :style="{ left: num + '%' }">{{num}} %</div>
            </div>
        </div>
        <div v-show="!spinner" class="bottom">
            <div class="bottom1">
                <div id="bottom-bar" :style="{ width: num + '%' }">
                    <div class="bottom-shadow"></div>
                </div>
            </div>
        </div>
        <p style="color: #409EFF;margin-top:20px;font-size: 14px;z-index: 99;">loading...</p>


      </div>

    </div>
  </transition>
</template>

<script>
  export default {
    data() {
      return {
        text: "loading...",
        spinner: null,
        background: null,
        fullscreen: true,
        visible: false,
        customClass: '',
        num: 0,
        t: '',
      };
    },
    mounted() {
        this.num = 0;
        // this.getNum()
    },
    methods: {
      resetNum() {
        this.num = 0
        clearInterval(this.t)
      },
      setNum(num) {
        this.num = num
        clearInterval(this.t)
      },
      getNum() {
        clearInterval(this.t)
        var that = this;
        var t = setInterval(function(){
            that.num+=1;
            if(that.num>=90){
                // alert(1)
                clearInterval(t);
            }
        },60)
      },
      handleAfterLeave() {
        this.num = 0;
        this.$emit('after-leave');
      },
      setText(text) {
        this.text = text;
      }
    }
  };
</script>
